<h1>Recommended Packages</h1>

<div class="row">
  <div class="col-md-8">
    <%= render collection: @projects, partial: 'subscriptions/project' %>
    <%= will_paginate @projects, page_links: false %>
  </div>
  <div class="col-md-4">
    <h3>
      <strong>
        What's this based on?
      </strong>
    </h3>
    <p>
      Recommendations are based on
      <% if current_user.github_enabled? %>
        data from your
        <%= link_to 'Profile', user_path(current_user.to_param) %> and
      <% end %>
      Libraries.io data.
    </p>
    <p>
      That includes packages your repositories depend on, packages you watch and popular packages written in languages you use.
    </p>
    <p>
      Not seeing anything interesting to you? <%= link_to 'Let us know.', 'mailto:support@libraries.io' %>
    </p>

    <h3>
      <strong>
        Filter by platform
      </strong>
    </h3>
    <div class="facets">
      <ul class='filter'>
        <% @platforms.each do |platform| %>
          <li class='<%= 'active' if platform.downcase == params[:platform].try(:downcase) %>'>
            <% if platform.downcase == params[:platform].try(:downcase) %>
              <%= link_to platform, url_for(params.merge(platform: nil).permit!) %>
            <% else %>
              <%= link_to platform, url_for(params.merge(platform: platform).permit!) %>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>

    <h3>
      <strong>
        Filter by language
      </strong>
    </h3>
    <div class="facets">
      <ul class='filter'>
        <% @languages.each do |language| %>
          <li class='<%= 'active' if language.downcase == params[:language].try(:downcase) %>'>
            <% if language.downcase == params[:language].try(:downcase) %>
              <%= link_to language, url_for(params.merge(language: nil).permit!) %>
            <% else %>
              <%= link_to language, url_for(params.merge(language: language).permit!) %>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>

    <h3>
      <strong>
        Filter by license
      </strong>
    </h3>
    <div class="facets">
      <ul class='filter'>
        <% @licenses.each do |license| %>
          <li class='<%= 'active' if license.downcase == params[:license].try(:downcase) %>'>
            <% if license.downcase == params[:license].try(:downcase) %>
              <%= link_to license, url_for(params.merge(license: nil).permit!) %>
            <% else %>
              <%= link_to license, url_for(params.merge(license: license).permit!) %>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>
  </div>
</div>
